package cn.jbolt.ec.retailer;

import cn.jbolt._admin.permission.CheckPermission;
import cn.jbolt._admin.permission.PermissionKey;
import cn.jbolt.base.JBoltBaseController;
import cn.jbolt.common.model.BecRetailerStaff;
import com.jfinal.aop.Inject;

@CheckPermission(PermissionKey.STAFF_ADMIN)
public class EcRetailerStaffAuthController extends JBoltBaseController {

    @Inject
    RetailerStaffService staffService;

    /**
     * 员工 管理的首页
     */

    @CheckPermission(PermissionKey.STAFF_INDEX)
    public void index(){
        set("pageData",staffService.get_retailer_staff_paginate(getPageNumber(),getPageSize(),getInt("retailerId"),getKeywords()));
        keepPara();
        render("index.html");
    }


    /**
     * 帮助商家添加员工
     */
    @CheckPermission(PermissionKey.STAFF_ADD)
    public void add(){
        render("add.html");
    }


    /**
     *  保存 商家添加员工
     */
    public void save_staff(){
        renderJson(staffService.save_staff(getModel(BecRetailerStaff.class,"staff"),getInt("member_id"),get("staff_name")));
    }


    public void delete_staff(){
        renderJson(staffService.delete_staff(getInt(0)));
    }

}
